package my;

import io.vertx.core.Vertx;
import io.vertx.core.eventbus.EventBus;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.shareddata.LocalMap;
import io.vertx.core.shareddata.SharedData;
import my.admin.AdminRestVerticle;

public class Starter {
	static Logger logger = LoggerFactory.getLogger(Starter.class);
	public static Vertx golableVertx=null;

	public static void main(String[] args) {
		Vertx vertx = Vertx.vertx();
		golableVertx=vertx;
		SharedData sharedData = vertx.sharedData();
		LocalMap<String, String> verticleNameIdMap = sharedData.getLocalMap("verticleNameIdMap");
		LocalMap<String, String> verticleIdNameMap = sharedData.getLocalMap("verticleIdNameMap");
		
		try {
			vertx.deployVerticle(AdminRestVerticle.class.getName(), res -> {
				if (res.succeeded()) {
					System.out.println("deploy admin success");

				} else {
					res.cause().printStackTrace();
					System.out.println(res.cause().getMessage());
				}
			});
			/*vertx.deployVerticle("http://localhost:2020/files/vertx-demo1-1.0-SNAPSHOT2.jar::DemoRestVerticle", res1 -> {
				if (res1.succeeded()) {
					logger.debug("deployVerticleSuccess");
					System.out.println("deployTestVerticleSuccess");
					// deployId=res.result()
					verticleNameIdMap.put("test", res1.result());
					verticleIdNameMap.put(res1.result(), "test");
					System.out.println("deployTestVerticleSuccess");
				} else {
					System.out.println("error");
					System.out.println(res1.cause());
				}
			});
			vertx.deployVerticle("http://localhost:2020/files/vertx-demo1-1.0-SNAPSHOT2.jar::DemoRestVerticle", res1 -> {
				if (res1.succeeded()) {
					logger.debug("deployVerticleSuccess");
					System.out.println("deployTestVerticleSuccess");
					// deployId=res.result()
					verticleNameIdMap.put("test", res1.result());
					verticleIdNameMap.put(res1.result(), "test");
					System.out.println("deployTestVerticleSuccess");
				} else {
					System.out.println("error");
					System.out.println(res1.cause());
				}
			});*/

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
